package com.xhl.lk.auth2.modules.admin.demo;

import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnels;

import static com.google.common.base.Charsets.UTF_8;

public class GuavaBloomFilterExample {

    public static void main(String[] args) {
        // 创建Bloom Filter，预计容量为10000，误判率为0.01
        BloomFilter<String> bloomFilter = BloomFilter.create(
                Funnels.stringFunnel(UTF_8),
                10000,
                0.01);

        // 添加元素到Bloom Filter
        bloomFilter.put("element1");
        bloomFilter.put("element2");

        // 检查元素是否存在于Bloom Filter
        System.out.println(bloomFilter.mightContain("element1")); // true
        System.out.println(bloomFilter.mightContain("element3")); // false
    }
}

